(function(ns) {

	var OpenWinScene = ns.OpenWinScene = Hilo.Class.create({
		Extends: Hilo.Container,
		constructor: function(properties) {
			OpenWinScene.superclass.constructor.call(this, properties);
			
			this.init(properties);

		},
		font:'36px arial',
		content:'采摘成功',
		init: function(properties) {

			var box = new Hilo.Bitmap({
				id: 'box',
				x:this.width * .5,
				y:this.height * .4,
				image: properties.image[0],
				rect: [0, 0, 500, 473]
			});
			var g1 = new Hilo.Graphics({
				width: this.width,
				height: this.height,
				x: 0,
				y: 0,
				background: "#8B8B8B",
				alpha: .5
			});
			var text = new Hilo.Text({
				id:"text",
			    font: this.font,
			    text: this.content,
			    lineSpacing: 1,
				color:"#AA6812"
				//background:"#000000"
			})
			
			// var toShow = new Hilo.Text({
			// 	id:"toshow",
			//     font: this.font,
			//     text: "去查看",
			// 	x:this.width * .5,
			//     lineSpacing: 1,
			// 	color:"#FFFFFF"
			// 	// background:"#FFFFFF"
			// })
			
			var btn1 = new Hilo.Bitmap({
				id: 'btn1',
				x:this.width * .5,
				y:this.height * .4,
				image: properties.image[1],
				rect: [0, 0, 180, 53]
			});
			
			var cha = new Hilo.Bitmap({
				id: 'cha',
				x:this.width * .5,
				y:this.height *.4,
				image: properties.image[2],
				rect: [0, 0, 51, 51]
			});
			
			
			
			g1.lineStyle(1, "#000000").beginFill("#000000").drawRect(0, 0, this.width, this.height).endFill().addTo(this);
			box.pivotX = box.width *.5
			box.pivotY = box.height *.5
			
			text.setFont("32px bolder")
			
			// console.log(text.textWidth)
			// console.log(mainelem)
				
			this.addChild(box,text,btn1,cha);
		},

		show: function(score, bestScore) {
			this.visible = true;
			
			
			this.getChildById('btn1').pivotX = this.getChildById('btn1').width *.5
			this.getChildById('btn1').pivotY = this.getChildById('btn1').height *.5
			this.getChildById('btn1').y = this.getChildById('box').y + this.getChildById('box').height *.33
			// this.getChildById('toshow').pivotX = this.getChildById('btn1').width *.25
			// this.getChildById('toshow').pivotY = this.getChildById('btn1').height *.25
			// this.getChildById('toshow').y = this.getChildById('box').y + this.getChildById('box').height *.33-3
			
			this.getChildById('cha').pivotX = this.getChildById('cha').width *.5
			this.getChildById('cha').pivotY = this.getChildById('cha').height *.5
			this.getChildById('cha').y= this.getChildById('box').y + this.getChildById('box').height * .5+50
			//文字
			let content="    " + window.game.InitData.award.prizeName
			var mainelem = new Hilo.Text({
				id:"mainelem",
			    font: "30px arial",
			    text: content,
				lineSpacing: 5,
				textVAlign:"middle",
				color:"#ffffff",
				// background:"#ffffff"
			}).addTo(this)
			//图片
			var guaicon = new Hilo.Bitmap({
			    image: window.game.InitData.award.thumbImg,
			    rect: [0, 0, 120, 120],
			}).addTo(this);
			
			setTimeout(()=>{
				
				this.getChildById('mainelem').height = 0
				this.getChildById('mainelem').width =  this.getChildById('box').width* .9
				// mainelem.height = box.height* .65
				this.getChildById('mainelem').maxWidth = this.getChildById('box').width* .9
				this.getChildById('mainelem').x = this.getChildById('box').x - this.getChildById('box').width *.45
				this.getChildById('mainelem').y= this.getChildById('box').y *.76
				
				guaicon.pivotX = guaicon.width /2
				guaicon.pivotY = guaicon.height /2
				guaicon.x = this.getChildById('box').x
				guaicon.y= this.getChildById('box').y + 15
				
				
				this.getChildById('text').x = this.getChildById('box').x - this.getChildById('text').textWidth* .5
				this.getChildById('text').y = this.getChildById('box').y - this.getChildById('box').height* .49
			},15)
			
			
			
			
			this.getChildById('btn1').on(Hilo.event.POINTER_START, function(e) {
			    e.stopImmediatePropagation && e.stopImmediatePropagation();
			    location.href = "app://gotoShopingCard";
			}.bind(this));
			
			this.getChildById('cha').on(Hilo.event.POINTER_START, function(e) {
			    e.stopImmediatePropagation && e.stopImmediatePropagation();
				//console.log(this)
				window.location.reload();
			    //this.hide();
			}.bind(this));
			
			
		},
		getReady(){
			this.visible = false
		},

		hide: function() {
			this.visible = false;

		}
	});

})(window.game);
